package com.github.ykrank.alipayxposed.app

import android.app.Activity
import android.os.Bundle
import android.text.TextUtils
import android.view.View
import android.widget.Toast
import com.github.ykrank.alipayxposed.R
import kotlinx.android.synthetic.main.activity_time_interval_config.*

class TimeIntervalConfigActivity : Activity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_time_interval_config)
    }


    fun confirm(v: View) {

        var appConfigHelper = AppConfigHelper.getInstance(this)
        var m = timeIntervalMinEditor.text.toString()
        var s = timeIntervalSecEditor.text.toString()
        if (TextUtils.isEmpty(m) && TextUtils.isEmpty(s)) {
            Toast.makeText(this, "时间间隔不能为空", Toast.LENGTH_SHORT).show()
            return
        }
        val minuteInterval = m.toInt()
        val secondInterval = s.toInt()
        appConfigHelper.saveTimeInterval(minuteInterval, secondInterval)


        //server address
        var apiAddress = serverAddressEditor.text.toString()
        if (apiAddress.isEmpty()) {
            Toast.makeText(this, "服务器地址不能为空", Toast.LENGTH_SHORT).show()
            return
        }
        appConfigHelper.saveApiAddress(apiAddress)

    }
}
